package com.rsk.service.impl;


import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.dubbo.config.annotation.Service;
import com.rsk.dao.SysUserLevelRepository;
import com.rsk.entity.SysUserLevel;
import com.rsk.service.SysUserLevelService;
import com.rsk.utils.algorithm.SnowflakeIdWorker;


@Service(interfaceClass = SysUserLevelService.class)
public class SysUserLevelServiceImpl implements SysUserLevelService{
	
	@Autowired
	private SysUserLevelRepository sysUserLevelRepository;
	
	@Transactional
	public int saveSysUserLevel(Long userId, Long levelId, Long operatorUser) {
		SysUserLevel sysUserLevel = new SysUserLevel();
		sysUserLevel.setId(SnowflakeIdWorker.generateId(true));
		sysUserLevel.setUserId(userId);
		sysUserLevel.setLevelId(levelId);
		sysUserLevel.setOperatorUser(operatorUser);
		sysUserLevel.setOperatorTime(new Date());
		sysUserLevelRepository.saveAndFlush(sysUserLevel);
		return 1;
	}

	@Transactional
	public int delSysUserLevel(Long id, Long operatorUser) {
		return sysUserLevelRepository.delSysUserLevel(id, operatorUser);
	}

	
	
	
}
